package hander

import (
	"github.com/gin-gonic/gin"
	"good/api/reponse"
	"good/api/request"
	"good/internal/dao"
	"good/internal/models"
)

func Comment(c *gin.Context) {
	req := request.Comment{}
	if err := c.ShouldBind(&req); err != nil {
		reponse.ErrorRequest(c, "绑定失败")
		return
	}
	user := models.Comment{
		ContentId: req.ContentId,
		UserId:    req.UserId,
		Content:   req.Content,
		LikeCount: req.LikeCount,
	}
	if err := dao.Comment(&user); err != nil {
		reponse.ErrorRequest(c, "评论提交失败")
		return
	}
	reponse.SuccessRequest(c, "评论提交成功", user)
}
